<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<body>
<div class="pull-left">
    <div class="form-group form-inline">
        总共${pageList.pages}页，共${pageList.total}条数据，每页10条, 当前第${pageList.pageNum}页。
    </div>
</div>

<div class="box-tools pull-right">
    <ul class="pagination">

        <c:if test="${pageList.pageNum!=1}">
            <li>
                <a href="javascript:toPage('1')" aria-label="Previous">首页</a>
            </li>
            <li>
                <a href="javascript:toPage('${pageList.pageNum-1}')">上一页</a>
            </li>
        </c:if>

        <c:forEach begin="${pageList.navigateFirstPage}" end="${pageList.navigateLastPage}" step="1" var="page">
            <c:if test="${pageList.pageNum != page}">
                <li>
                    <a href="javascript:toPage('${page}')">${page}</a>
                </li>
            </c:if>
            <c:if test="${pageList.pageNum == page}">
                <li>
                    <a style="background: skyblue">${page}</a>
                </li>
            </c:if>
        </c:forEach>


        <c:if test="${pageList.pageNum!=pageList.pages}">
            <li>
                <a href="javascript:toPage('${pageList.pageNum+1}')">下一页</a></li>
            <li>
                <a href="javascript:toPage('${pageList.pages}')" aria-label="Next">尾页</a>
            </li>
        </c:if>

    </ul>
</div>


<form id="formId" action="${param.pageUrl}" method="post">
    <input id="pageNum" type="hidden" name="pageNum">
    <input id="pageSize" type="hidden" name="pageSize">
</form>

<script>
    function toPage(pageNum) {
        // 给表单的pageNum赋值
        $("#pageNum").val(pageNum);
        document.getElementById("pageSize").value = document.getElementById("size").value;
        /*$("#pageSize").val($("#size").val);*/
        // 让表单提交
        $("#formId").submit();
    }
</script>

</body>
</html>
